home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-09-29 | 2.7 KB | 124 lines | [TEXT/KAHL] |
- #include <stdlib.h>
-
- #include <Windows.h>
- #include <QDOffscreen.h>
- #include <Memory.h>
- #include <Fonts.h>
- #include <Packages.h>
- #include <SegLoad.h>
- #include <ToolUtils.h>
- #include <TextEdit.h>
- #include <Files.h>
-
- #include "C_randomizer.h"
-
- #include "general.h"
- #include "port.h"
- #include "gworld.h"
- #include "stereopair.h"
-
- stereopair::stereopair( int breedte, int hoogte,
- int backDisparity, CTabHandle cTable)
- {
- my_leftDisparity = backDisparity / 2;
- my_rightDisparity = my_leftDisparity - backDisparity;
-
- L = new gworld( breedte, hoogte, 1);
- R = new gworld( breedte, hoogte, 1);
- LR = new gworld( breedte, hoogte, 2, cTable);
-
- if( my_leftDisparity != 0)
- {
- left_noise = new gworld( abs( my_leftDisparity), hoogte, 1);
- } else {
- left_noise = 0;
- }
- if( my_rightDisparity != 0)
- {
- right_noise = new gworld( abs( my_rightDisparity), hoogte, 1);
- } else {
- right_noise = 0;
- }
- leftNoiseRect.top = 0;
- leftNoiseRect.left = 0;
- leftNoiseRect.bottom = hoogte;
- leftNoiseRect.right = abs( my_leftDisparity);
-
- leftNoiseImageRect = leftNoiseRect;
-
- rightNoiseRect.top = 0;
- rightNoiseRect.left = 0;
- rightNoiseRect.bottom = hoogte;
- rightNoiseRect.right = abs( my_rightDisparity);
-
- rightNoiseImageRect = rightNoiseRect;
-
- if( my_leftDisparity < 0)
- {
- OffsetRect( &leftNoiseImageRect, breedte + my_leftDisparity, 0);
- }
- if( my_rightDisparity < 0)
- {
- OffsetRect( &rightNoiseImageRect, breedte + my_rightDisparity, 0);
- }
- }
-
- stereopair::~stereopair()
- {
- delete L;
- delete R;
- if( left_noise != 0)
- {
- delete left_noise;
- }
- if( right_noise != 0)
- {
- delete right_noise;
- }
- delete LR;
- }
-
- void stereopair::CleanSheet() const
- {
- L->fill_random();
- R->copyfrom( *L);
- L->scroll( my_leftDisparity, 0);
- R->scroll( my_rightDisparity, 0);
- //
- // fill in the 'exposed parts' of the rectangles with new random noise:
- //
- if( left_noise != 0)
- {
- left_noise->fill_random();
- L->copyfrom( *left_noise, leftNoiseRect, leftNoiseImageRect);
- }
- if( right_noise != 0)
- {
- right_noise->fill_random();
- R->copyfrom( *right_noise, rightNoiseRect, rightNoiseImageRect);
- }
- }
-
- void stereopair::AddRect( short x, short y, short width, short height,
- int leftDisparity, int rightDisparity) const
- {
- gworld newNoise( width, height, 1);
- newNoise.fill_random();
-
- const short leftX = x + leftDisparity;
- const short rightX = x + rightDisparity;
-
- const Rect noiseRect = {0, 0, height, width};
- const Rect leftRect = {y, leftX, y + height, leftX + width};
- const Rect rightRect = {y, rightX, y + height, rightX + width};
-
- L->copyfrom( newNoise, noiseRect, leftRect);
- R->copyfrom( newNoise, noiseRect, rightRect);
- }
-
- const gworld *stereopair::GetImage() const
- {
- LR->two_bit_merge( *L, *R);
- return LR;
- }
-